 #include <iostream>  
 #include <cstdio>  
 #include <cstring>  
 using namespace std;  
 struct node  
 {  
	int x, y;  
 }f[330][330];  
 node findy(int x,int y)  
 {  
	if(f[x][y].x == x && f[x][y].y == y) return f[x][y];  
	f[x][y] = findy(f[x][y].x,f[x][y].y);  
	return f[x][y];  
 }  
 int main()  
 {
	int n, m, i, j;  
	cin >> n >> m;
	    for(i = 1; i <= n; ++ i)  
		  for(j = 1; j <= n; ++ j)  
			 f[i][j].x = i, f[i][j].y = j;  
	    int x, y, flag = 0;  
	    char ch;  
	    for(i = 1; i <= m; ++ i)  
	    {  
		   cin >> x >> y >> ch;  
		   if(flag)  continue;  
		   node a = findy(x,y), b;  
		   if(ch == 'D')  
			 b = findy(x+1,y);  
		   else b = findy(x,y+1);  
		   if(a.x == b.x && a.y == b.y)  
		   {  
			  cout << i << endl;  
			  flag = 1;  
		}  
		else f[b.x][b.y] = a;  
	    }  
	if(flag == 0)
	cout << "draw" << endl;  
	return 0;  
 }  
